#include "fan.h"
/* 设置风扇的转速 */
void Set_Fan_Speed(FAN_SPEED speed)
{
    switch (speed){
        case FAN_SPEED_LEVEL_0:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 0); // 设置占空比为 0%
            break;
        case FAN_SPEED_LEVEL_1:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 100); // 设置占空比为 10%
            break;
        case FAN_SPEED_LEVEL_2:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 200); // 设置占空比为 20%
            break;
        case FAN_SPEED_LEVEL_3:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 300); // 设置占空比为 30%
            break;
        case FAN_SPEED_LEVEL_4:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 400); // 设置占空比为 40%
            break;
        case FAN_SPEED_LEVEL_5:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 500); // 设置占空比为 50%
            break;
        case FAN_SPEED_LEVEL_6:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 600); // 设置占空比为 60%
            break;
        case FAN_SPEED_LEVEL_7:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 700); // 设置占空比为 70%
            break;
        case FAN_SPEED_LEVEL_8:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 800); // 设置占空比为 80%
            break;
        case FAN_SPEED_LEVEL_9:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 900); // 设置占空比为 90%
            break;
        case FAN_SPEED_LEVEL_10:
            __HAL_TIM_SetCompare(&Fan_PWM_TIM_Handle, PWM_CHANNELx, 1000); // 设置占空比为 100%
            break;
        default:
            break;
    }
}
/* 设置风扇状态 */
void Set_Fan_State(FAN_STATE state)
{
    if(state == FAN_STATE_ON) // 风扇开
       FAN_START();
    else if(state == FAN_STATE_OFF) // 风扇关
       FAN_STOP();
}